<template>
  <div class="promo-cards">
    <div class="promo-header">
      <h3>{{ title }}</h3>
      <a href="#" class="more-link">更多 <el-icon><ArrowRight /></el-icon></a>
    </div>
    <div class="cards-container">
      <div v-for="(item, index) in promoList" :key="index" class="promo-card">
        <a :href="item.link">
          <div class="card-image">
            <img :src="item.imgUrl" :alt="item.title">
            <div v-if="item.tag" class="card-tag" :style="{ backgroundColor: item.tagColor || '#e1251b' }">{{ item.tag }}</div>
          </div>
          <div class="card-title">{{ item.title }}</div>
          <div v-if="item.price" class="card-price">¥{{ item.price.toFixed(2) }}</div>
        </a>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ArrowRight } from '@element-plus/icons-vue';

const props = defineProps({
  title: {
    type: String,
    default: '优惠活动'
  },
  promoList: {
    type: Array,
    required: true
  }
});
</script>

<style lang="scss" scoped>
.promo-cards {
  background-color: white;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  
  .promo-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    
    h3 {
      font-size: 20px;
      font-weight: bold;
      color: #333;
      position: relative;
      padding-left: 12px;
      
      &:before {
        content: '';
        position: absolute;
        left: 0;
        top: 50%;
        transform: translateY(-50%);
        width: 4px;
        height: 18px;
        background-color: var(--primary-color);
        border-radius: 2px;
      }
    }
    
    .more-link {
      font-size: 14px;
      color: #999;
      display: flex;
      align-items: center;
      
      &:hover {
        color: var(--primary-color);
      }
      
      .el-icon {
        margin-left: 5px;
      }
    }
  }
  
  .cards-container {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    
    @media (max-width: 1200px) {
      grid-template-columns: repeat(3, 1fr);
    }
    
    @media (max-width: 992px) {
      grid-template-columns: repeat(2, 1fr);
    }
  }
  
  .promo-card {
    position: relative;
    transition: all 0.3s;
    border-radius: 4px;
    overflow: hidden;
    
    &:hover {
      transform: translateY(-5px);
      box-shadow: 0 5px 15px rgba(0,0,0,0.1);
      
      .card-image img {
        transform: scale(1.05);
      }
    }
    
    .card-image {
      position: relative;
      height: 180px;
      overflow: hidden;
      
      img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        transition: transform 0.5s;
      }
      
      .card-tag {
        position: absolute;
        top: 10px;
        right: 10px;
        padding: 2px 8px;
        font-size: 12px;
        color: white;
        border-radius: 3px;
        background-color: var(--primary-color);
      }
    }
    
    .card-title {
      font-size: 14px;
      margin: 10px 0;
      line-height: 1.4;
      height: 40px;
      overflow: hidden;
      display: -webkit-box;
      -webkit-line-clamp: 2;
      -webkit-box-orient: vertical;
    }
    
    .card-price {
      font-size: 18px;
      color: var(--primary-color);
      font-weight: bold;
    }
  }
}
</style> 